﻿
using System;
using System.Xml;
namespace Mota.XMLControls
{
    //singleton
    public class GuiBuilder
    {
        private static volatile GuiFactory currentGuiFactory = null;
        //static synchronization root object
        private static object m_syncRoot = new object();

        public static GuiFactory CurrentFactory
        {
            get
            {
                if(currentGuiFactory == null)
                {
                    lock (m_syncRoot)
                    {
                        currentGuiFactory = new DXGuiFactory();
                    }
                }
                return currentGuiFactory;
            }
        }
        public static object GetVisualFrom(GuiControl guiControl)
        {
            return guiControl.visualControl;
        }
        public static GuiFactory SetGuiFactory(GuiFactory factory)
        {
            if (factory == null)
                throw new ArgumentNullException("factory");

            lock (m_syncRoot)
            {
                currentGuiFactory = factory;
            }
            
            return currentGuiFactory;
        }

    }
}
